package com.epoint.mobileoa.personalized.epointcompany.ui.kaoqing;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class GPSInfo {

	private String detaileInfo;
	private String mRoadName;
	private String mName;
	private int locType;
	private String error;

	public String getAddress() {
		// Log.i("tracy", detaileInfo);
		// String address = StringHelp.getXMLAtt(detaileInfo,
		// "formatted_address");
		// if (address.indexOf(" ") != -1) {
		// address = address.substring(0, address.indexOf(" "));
		// }
		String address = "";
		if (getRoadName().length() != 0) {
			address = getRoadName();
		}
		if (getName()!=null&&!getName().equals("")) {
			address = getRoadName() + "[" + getName() + "]";
		}

		return address;
	}

	public void setPoi(String poi) throws JSONException {
		Log.i("tracy", "poi=" + poi);

		JSONObject jsonObject = new JSONObject(poi).getJSONArray("p")
				.getJSONObject(0);
		Log.i("tracy", "jsonObject.name=" + jsonObject.getString("name"));
		setName(jsonObject.getString("name"));
	}

	public String getDetaileInfo() {
		return detaileInfo;
	}

	public void setDetaileInfo(String detaileInfo) {
		this.detaileInfo = detaileInfo;
	}

	public String getRoadName() {
		return mRoadName;
	}

	public void setRoadName(String roadName) {
		if ("null".equals(roadName) || null == roadName) {
			return;
		}
		this.mRoadName = roadName;
	}

	public String getName() {
		if(mName==null)
		{
			return "";
		}
		return mName;
	}

	public void setName(String name) {
		if ("null".equals(name) || null == name) {
			return;
		}
		if (name.equals("沙洲职业工学院教学实训基地")) {
			this.mName = "江苏国泰新点软件有限公司";
		} else {
			this.mName = name;
		}
	}

	public int getLocType() {
		return locType;
	}

	public void setLocType(int locType) {

		this.locType = locType;
		if (getLocType() != 61 && getLocType() != 161) {
			this.mRoadName = "";
			this.mName = "";
		}
		switch (locType) {
		case 62:
			this.error = " 扫描整合定位依据失败。此时定位结果无效";
			break;
		case 63:
			this.error = "网络异常，没有成功向服务器发起请求。此时定位结果无效";
			break;
		// case 65:
		// this.error="";
		// break;
		case 162:
		case 163:
		case 164:
		case 165:
		case 166:
		case 167:
			this.error = "服务端定位失败";
			break;
		}
	}

	// 61 ： GPS定位结果
	// 62 ： 扫描整合定位依据失败。此时定位结果无效。
	// 63 ： 网络异常，没有成功向服务器发起请求。此时定位结果无效。
	// 65 ： 定位缓存的结果。
	// 161： 表示网络定位结果
	// 162~167： 服务端定位失败。

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

}
// {"p":[{"addr":"江苏省苏州市张家港市","y":"31.901652","dis":"109.767190","x":"120.548038","name":"沙洲职业工学院教学实训基地","tel":""}]}
